<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//$content = $_GET["arrQuestion"];
$content = json_decode($_GET["arrQuestion"], JSON_FORCE_OBJECT);
$input = $_GET["input"];
$type = intval($_GET["type"]);

//switch (type){
//   case 2:
//
//        break;
//    case 1:

        for( $i = 0 ; $i < count($content) ; ++$i)
        {
            echo $content[$i]['title'].'titiel';
            $body = "";
            $body .= "<h4>".$content[$i]['title']."</h4><br>";
            $body .= "<h6>A. ".$content[$i]['answer1']."</h6><br>";
            $body .= "<h6>B. ".$content[$i]['answer2']."</h6><br>";
            $body .= "<h6>C. ".$content[$i]['answer3']."</h6><br>";
            $body .= "<h6>D. ".$content[$i]['answer4']."</h6><br>";
            $body .= $input;

            $post = new ElggObject();

            $post->subtype = "thewire";
            $post->owner_guid = elgg_get_logged_in_user_guid();
            $post->access_id = ACCESS_PUBLIC;

            // only 200 characters allowed
            $text = elgg_substr($body, 0, 500); // default is 200 characters

            // no html tags allowed so we escape
            $post->description = $text;//htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');

            $post->method = "site"; //method: site, email, api, ...

            $guid = $post->save();

            if ($guid) {
				add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);

		// let other plugins know we are setting a user status
		$params = array(
			'entity' => $post,
			'user' => $post->getOwnerEntity(),
			'message' => $post->description,
			'url' => $post->getURL(),
			'origin' => 'thewire',
		);
		elgg_trigger_plugin_hook('status', 'user', $params);
            }

            if( !$guid)
                echo "Failed";
        }

        
    if(count($content))
      echo "Posted";
//    break;
//    default:
////        break;
//}
?>
